<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://unpkg.com/vue"></script>
    <script>
        window.onload = function () {

            var app3 = new Vue({
                el: '#app',
                methods: {
                    addpeople: function () {
                     var  x=  {name:this.username ,age:this.age,time:new Date()};
                        this.peoples.push(x);
                    },
                    removell:function(){
                        this.username=null;
                        this.age=null;
                    },
                    removeall:function(){this.peoples=[];}
                   , remove:function(index){
                        this.peoples.splice(index,1)
                    }
                },
                data: {
                    username:'',
                    age:null,
                    message: 'Hello Vue.js!',
                    peoples: [
                        {name: '罗军', age: 18,time:new Date},
                        {name: '吕领领', age: 188888,time:new Date},
                    ]
                }
                ,filters:{
                    hhmmss:function(v){
                        return (v.getHours()+";"+v.getMinutes()+":"+v.getSeconds())
                    }
                   , capitalize: function (value) {
                        if (!value) return ''
                        value = value.toString()
                        return value.charAt(0).toUpperCase() + value.slice(1)
                    }
                }
            });
                }
    </script>
</head>
<body>



<div id="app">
    <p>{{ message }}</p>
    <input v-model="username"><br/>
    <input v-model="age"><br/>
    <button v-on:click="addpeople">添加</button>
    <button v-on:click="removeall">全部删除</button>
    <button v-on:click="removell">重置</button><br/>
    <table border="1">
        <tr>
            <th>序号</th>
            <th>名字</th>
            <th>年龄</th>
            <th>添加时间</th>
            <th>操作</th>
        </tr>
        <tr v-for="(people,index) in peoples">
            <td>{{index+1}}</td>
            <td>{{people.name|  capitalize}}</td>
            <td>{{people.age}}</td>
            <td>{{people.time|hhmmss}}</td>
        <td><button v-on:click="remove(index)">删除</button></td>
     </tr>
    </table>
</div>
</body>
</html>